package com.qezhhnjy.mall.order.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.order.OrderSetting;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.order.service.OrderSettingService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 订单配置信息 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "订单配置信息接口")
@Slf4j
@RequestMapping("/order-setting")
public class OrderSettingController {
    @Resource
    private OrderSettingService orderSettingService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取订单配置信息信息")
    public BaseResult<OrderSetting> get(Long id) {
        OrderSetting orderSetting = orderSettingService.getById(id);
        return BaseResult.success(orderSetting);
    }

    @PostMapping("/save")
    @Operation(summary = "新增订单配置信息信息")
    public BaseResult<OrderSetting> save(@RequestBody OrderSetting orderSetting) {
        orderSettingService.save(orderSetting);
        return BaseResult.success(orderSetting);
    }

    @PutMapping("/update")
    @Operation(summary = "更新订单配置信息信息")
    public BaseResult<OrderSetting> update(@RequestBody OrderSetting orderSetting) {
        orderSettingService.updateById(orderSetting);
        return BaseResult.success(orderSetting);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取订单配置信息信息")
    public BaseResult<Page<OrderSetting>> page(@RequestBody Page<OrderSetting> page) {
        orderSettingService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除订单配置信息信息")
    public BaseResult<Long> delete(Long id) {
        orderSettingService.removeById(id);
        return BaseResult.success(id);
    }
}

